package cn.hinglo.gameclaw.admin.dao;

import cn.hinglo.gameclaw.admin.entity.MenuClawEntity;
import cn.hinglo.gameclaw.data.dbdao.MyMapper;
import cn.hinglo.gameclaw.user.bean.MenuClaw;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * @createTime: 2018/1/8
 * @author: HingLo
 * @description: 娃娃机分类管理
 */
@Repository
public interface MenuClawDao extends MyMapper<MenuClaw> {
    /**
     * 根据指定的分类来查询该分类下色娃娃机
     *
     * @param mid 分类的ID
     * @return 菜单下的娃娃机列表
     */
    @Select("SELECT  mc.id as id,c.header as img,cid,c.name as name,c.gold as gold,mc.date as date,mc.sort as sort,mc.edate as edate,c.live1,c.live2,room_id from claw as c,menu_claw as mc where c.id=mc.cid and c.id in (SELECT cid from menu_claw WHERE mid=#{mid})")
    List<MenuClawEntity> listMenuClawDao(String mid);

    /**
     * 修改人工权重值
     *
     * @param id   分类下的唯一Id
     * @param sort 权重
     * @param date 截止时间
     * @return 修改结果
     */
    @Update("update menu_claw set sort=#{sort} ,edate=#{date} where id=#{id}")
    int updateMenuClawDao(@Param("id") String id, @Param("sort") Integer sort, @Param("date") Date date);
}
